<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html" 
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	template="../template/layout.xhtml">

	<ui:define name="content">
		  <h:form id="form" enctype="multipart/form-data" >
			<p:messages showDetail="true"/>  
		  	
		  	
		  	<h1 class="titulo-h1">Cadastro de Produtos/Serviços</h1>
			<p:panel id="panel" style="width:100%;border:0;">
				<h:inputHidden value="#{produtoMB.bean.codigo}"/>

				<h:panelGrid columns="3" style="width:50%">
					<h:outputText value="Nome:" />
					<p:inputText id="nome" required="true" value="#{produtoMB.bean.nome}" requiredMessage="Valor Obrigatorio" style="width:300px;"/>
					<p:message for="nome"/>  
				</h:panelGrid>
				
				<h:panelGrid columns="1" style="width:50%">
					<h:outputText value="Foto:" /><br></br>
						<p:graphicImage value="#{produtoMB.graphicText}" width="73.15%"  id="foto" />  
						<p:fileUpload style="width:75%" fileUploadListener="#{produtoMB.handleFileUpload}"
									  mode="advanced"
									  auto="true"   
									  update="foto"
		            				  sizeLimit="1000000" 
		            				  allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
		            	/>
	            	
				</h:panelGrid>
					
				<h:panelGrid columns="3" style="width:100%">
					<h:outputText  value="Tipo:" />
					<p:selectOneMenu style="width:100px;" value="#{produtoMB.bean.tipo}">
						<f:selectItem itemLabel="Produto" itemValue="Produto" />
						<f:selectItem itemLabel="Servico" itemValue="Servico"/>
					</p:selectOneMenu>
					<br/>
					
					<h:outputText value="Descricao:" />
					<p:inputTextarea style="margin-bottom:10px;" rows="6" cols="70" value="#{produtoMB.bean.descricao}"/>  
					<br />
					
					
					 <p:commandButton  value="Salvar" ajax="false" action="#{produtoMB.salvar}"/> 
					 <p:commandButton value="Voltar" action="#{produtoMB.listar}" ajax="false" immediate="true"/>
					   
				</h:panelGrid>
			</p:panel>
		</h:form>
	</ui:define>

</ui:composition>